package cn.net.shuxing.yifu.common.service;

import cn.net.shuxing.yifu.common.bean.RedisData;
import cn.net.shuxing.yifu.common.mapper.RedisDataMapper;
import cn.net.shuxing.yifu.common.util.CommonExample;
import org.springframework.stereotype.Service;

@Service
public class RedisDataService extends BaseService<RedisData,RedisDataMapper> {

    public boolean set(String key, String value)
    {
        CommonExample example = new CommonExample(RedisData.class);
        example.equals("redisKey",key);
        RedisData redisData = getByExample(example);
        if (redisData != null)
        {
            redisData.setRedisValue(value);
            update(redisData);
            return true;
        }
        return false;
    }
    public String get(String key)
    {
        CommonExample example = new CommonExample(RedisData.class);
        example.equals("redisKey",key);
        RedisData redisData = getByExample(example);
        if (redisData != null)
            return redisData.getRedisValue();
        return "";
    }

    public void insert(String key, String value)
    {
        RedisData redisData = new RedisData();
        redisData.setRedisKey(key);
        redisData.setRedisValue(value);
        insert(redisData);
    }


}
